package com.yanqu.road.server.manger.activity.recycle;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.ActivityItemRecycleData;
import com.yanqu.road.entity.config.goods.GoodsInfo;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.enums.eGoodsType;
import com.yanqu.road.entity.player.UserBagItem;
import com.yanqu.road.server.manger.activity.chinesechess.ChineseChessMgr;
import com.yanqu.road.server.manger.config.GoodsMgr;

import java.util.ArrayList;
import java.util.Map;

public class ChineseChessRecycleStrategy extends AbstractItemRecycleStrategy {
    @Override
    public void markNeedRecycleItem() {
        ActivityInfo activityInfo = ChineseChessMgr.getActivityInfo();
        if (activityInfo != null) {
            long recycleTime = activityInfo.getEndTime() * 1000L + 600 * 1000;
            //todo-xx 回收皮肤道具和对应的对局卡先
            Map<Integer, GoodsInfo> goodsMap = GoodsMgr.getGoodsMapByType(eGoodsType.ChineseChessSkin.getValue());
            for(GoodsInfo goodsInfo : goodsMap.values()){
                ActivityItemRecycleMgr.addRecycleItemData(goodsInfo.getGoodsId(), activityType, 1, recycleTime, new ArrayList<>());
            }
            ActivityItemRecycleMgr.addRecycleItemData(ChineseChessMgr.getPlayItemId(), activityType, 1, recycleTime, new ArrayList<>());
            ActivityItemRecycleMgr.addRecycleItemData(ChineseChessMgr.getChineseChessReviveItemId(), activityType, 1, recycleTime, new ArrayList<>());
        }
    }

    @Override
    protected void initActivityType() {
        activityType = eActivityType.ChineseChess.getValue();
    }

    @Override
    protected void doRecycle(long userId, ActivityItemRecycleData data) {
        UserBagItem item = getUserBagItem(userId,data.getItemId());
        if(item != null && item.getNum() > 0){
            removeItem(item);
        }
    }

    @Override
    public boolean isActivityRunning() {
        return false;
    }
}
